<template>
    <div class="integral_box">
        <div class="top">
            <div class="item_inter">
                <div class="number">{{integralTotal.all}}</div>
                <div class="tips">累计获得</div>
            </div>
            <div class="item_inter mar_tab">
                <div class="number">{{integralTotal.now}}</div>
                <div class="tips">当前积分</div>
            </div>
            <div class="tab_btn" @click="description=true">积分兑换</div>
        </div>
        <div class="integral_list">
            <div class="head_top">
                <div class="time">时间</div>
                <div class="type">类型</div>
                <div class="integral">积分</div>
            </div>
            <div class="contents">
                <div class="head_top body_content" v-for="(item,index) in integralList" :key="index">
                    <div class="time">{{item.time}}</div>
                    <div class="type">{{item.type}}</div>
                    <div class="integral" :class="{'out_active':item.state==2}">{{item.state==2?'-':'+'}}{{item.num}}</div>
                </div>
            </div>
            <div class="block">
                <el-pagination
                    background
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-size="limit"
                    layout="total, prev, pager, next, jumper"
                    :total="total">
                </el-pagination>
            </div>
        </div>
        <el-dialog class="integral-dialog" :visible.sync="description" center title="积分兑换说明" fullscreen>
            <div class="city_location_box">
                <div class="txt" v-html="integralInfo"></div>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import {getIntegralList, getIntegralText, getIntegralTotal} from "@/api/apis";

    export default {
        name: "integralView",
        data() {
            return {
                integralTotal: {},
                currentPage: 1,
                limit: 10,
                total: 0,
                integralList: [],
                description: false,
                integralInfo: ''
            }
        },
        methods: {
            GetIntegralTotal() {
                getIntegralTotal().then(res => {
                    this.integralTotal = res.data
                })
            },
            GetIntegralList() {
                let data = {page: this.currentPage, limit: this.limit}
                getIntegralList(data).then(res => {
                    this.integralList = res.data.data
                    this.total = res.data.total
                })
            },
            GetIntegralText() {
                getIntegralText().then(res => {
                    this.integralInfo = res.data.text
                })
            },
            handleCurrentChange(e) {
                this.currentPage = e
                this.GetIntegralList()
            },
        },
        mounted() {
            this.GetIntegralTotal()
            this.GetIntegralList()
            this.GetIntegralText()
        }
    }
</script>
<style lang="less">
    .integral-dialog {
        .el-dialog__header {
            border-bottom: 2px solid #E9E9E9;
        }
        .city_location_box {
            table {
                display: block;
                max-width: 100%;
                th {
                    display: block;
                    max-width: 100%;
                }
                td {
                    display: block;
                    max-width: 100%;
                }
            }
            img {
                max-width: 100%;
            }
        }
    }
</style>
<style scoped lang="less">
    .integral_box {
        .top {
            margin-left: 43px;
            display: flex;
            align-items: center;
            margin-bottom: 38px;
            
            .item_inter {
                text-align: center;
                
                .number {
                    font-size: 24px;
                    font-family: Microsoft YaHei;
                    font-weight: bold;
                    color: #000000;
                    margin-bottom: 6px;
                }
                
                .tips {
                    font-size: 14px;
                    font-family: Microsoft YaHei;
                    font-weight: 400;
                    color: #000000;
                }
            }
            
            .mar_tab {
                margin: 0 79px 0 93px;
            }
            
            .tab_btn {
                width: 80px;
                height: 28px;
                background: #B11E24;
                font-size: 12px;
                font-family: Microsoft YaHei;
                font-weight: 400;
                line-height: 28px;
                color: #FFFFFF;
                text-align: center;
            }
        }
        
        .integral_list {
            .head_top {
                display: flex;
                align-items: center;
                height: 36px;
                background: #000000;
                font-size: 14px;
                font-family: Microsoft YaHei;
                font-weight: 400;
                color: #FFFFFF;
                text-align: center;
                
                .time {
                    width: 153px;
                }
                
                .type {
                    width: 523px;
                }
                
                .integral {
                    width: 524px;
                }
            }
            
            .body_content {
                color: #000000;
                background: #FFFFFF;
                height: 48px;
                border-bottom: 1px solid #C7C7C7;
                
                .out_active {
                    color: #B11E24;
                }
            }
            
            .contents {
                min-height: 60vh;
            }
        }
    }
    
    .city_location_box {
        position: fixed;
        background: #FFFFFF;
        top: 60px;
        left: 50%;
        transform: translateX(-50%);
        bottom: 0;
        z-index: 8;
        padding: 20px;
        width: 684px;
        overflow-x: hidden;
        overflow-y: auto;
        text-align: left;
        
        .txt {
            font-size: 14px;
            font-family: Microsoft YaHei;
            font-weight: 400;
            line-height: 17px;
            color: #000000;
            
            /deep/ img {
                max-width: 100%;
                height: auto;
            }
        }
        
        .location_box {
            width: 1200px;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            border: 1px solid #9D9D9D;
            padding: 32px 0 30px;
            z-index: 10;
            background: #FFFFFF;
            
            .tips_title {
                font-size: 24px;
                font-family: Microsoft YaHei;
                font-weight: 400;
                color: #000000;
                font-weight: bold;
                margin-bottom: 17px;
                text-align: center;
            }
            
            .line {
                height: 2px;
                background: #E9E9E9;
                box-sizing: border-box;
                margin-bottom: 37px;
            }
            
            .close {
                width: 18px;
                height: 18px;
                position: absolute;
                z-index: 7;
                right: 10px;
                cursor: pointer;
                top: 10px;
            }
            
            .content_box_infos_tabcar {
                width: 1000px;
                margin: 0 auto 30px;
                max-height: 550px;
                overflow-y: scroll;
                min-height: 550px;
                
                .txt {
                    width: 990px;
                    font-size: 14px;
                    font-family: Microsoft YaHei;
                    font-weight: 400;
                    line-height: 17px;
                    color: #000000;
                    
                    /deep/ img {
                        max-width: 100%;
                        height: auto;
                    }
                }
            }
            
            .content_box_infos_tabcar::-webkit-scrollbar { /*滚动条整体样式*/
                width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
                height: 1px;
            }
            
            .content_box_infos_tabcar::-webkit-scrollbar-thumb { /*滚动条里面小方块*/
                border-radius: 10px;
                -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
                background: #535353;
            }
            
            .content_box_infos_tabcar::-webkit-scrollbar-track { /*滚动条里面轨道*/
                -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
                border-radius: 10px;
                background: #EDEDED;
            }
        }
    }
</style>
